/*
 * @desc:
 * @Author: 钟强
 * @Date: 2021-03-26 15:11:10
 * @LastEditors: 钟强
 * @LastEditTime: 2021-03-26 15:11:21
 * @Description: file content
 */

const path = require('path');
module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? './' : '/',
  lintOnSave: false,
  productionSourceMap: false,
  runtimeCompiler: true,
  devServer: {
    port: '8080',
    proxy: {
      '/': {
        target: 'http://hrx2-ci.hrx.pingan.com.cn',
        changOrigin: true,
        pathRewrite: {
          '^/': '/'
        }
      }
    }
  },
  css: {
    loaderOptions: {
      postcss: {
        plugins: () => [
          require('postcss-px2rem')({
            remUnit: 37.5
          })
        ]
      }
    }
  },
  pluginOptions: {
    // 支持全景less变量
    'style-resources-loader': {
      preProcessor: 'less',
      patterns: [
        path.resolve(__dirname, './src/assets/styles/base.less')
      ]
    }
  },
  configureWebpack: {
    devtool: process.env.NODE_ENV === 'production' ? 'false' : 'source-map',
    resolve: {
      modules: [path.resolve(__dirname, 'views'), 'node_modules'],
      alias: {
        vue$: 'vue/dist/vue.esm.js',
        '@': path.join(__dirname, 'src')
      }
    }
  },
  chainWebpack: (config) => {
    // 生成 report.html 以帮助分析包内容
    if (process.env.npm_config_report) {
      config
        .plugin('webpack-bundle-analyzer')
        .use(require('webpack-bundle-analyzer').BundleAnalyzerPlugin);
    }
  }
};
